package org.weishe.pagerank;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class PreReducer extends Reducer<Text, IntWritable, IntWritable, NullWritable> {
	private IntWritable sum = new IntWritable(0);
	private Text count = new Text("count");

	@Override
	protected void reduce(Text key, Iterable<IntWritable> values,
			Reducer<Text, IntWritable, IntWritable, NullWritable>.Context context)
					throws IOException, InterruptedException {
		int iSum = 0;
		for (IntWritable v : values) {
			iSum = iSum + v.get();
		}
		sum.set(iSum);
		context.write(sum, NullWritable.get());
	}
}